Repository navigation
managed-fund: test the price feed and recipient errors, and check quasar withdraw's USDC recipient - #214
Open
mikemaccana wants to merge 2 commits into
Open
managed-fund: test the price feed and recipient errors, and check quasar withdraw's USDC recipient#214mikemaccana wants to merge 2 commits into
mikemaccana wants to merge 2 commits into
Conversation
added 2 commits
November 10, 2026 17:03
No test triggered InvalidPriceFeed, NegativePrice, StalePriceFeed or InvalidRecipient. Each check now has a test that asserts the exact error and that no tokens or shares moved, then shows the honest path succeeds: - another asset's price feed, in a deposit and a rebalance (InvalidPriceFeed) - a price account too short for a Pyth price update (InvalidPriceFeed) - a price of zero and a negative price (NegativePrice) - a price 61 seconds old, refused, and one 60 seconds old, accepted (StalePriceFeed) - a withdrawal paying an asset to someone else's account, or to an account for another mint (InvalidRecipient) - quasar only, where these checks raise InvalidRecipient: a deposit or a fee collection minting shares to someone else's share account Applied to anchor-v1, anchor and quasar. With each check removed from the program, its test fails. Claude-Session: https://claude.ai/code/session_01GZHin6BQpAqf7j2ucSZWkx
withdraw checked that each asset leg is paid to an account the holder owns for that asset's mint, but paid the USDC leg to whatever user_usdc_account the caller named. The Anchor versions require it to be the holder's USDC associated token account. The quasar version now checks its owner and mint, failing with InvalidRecipient, and test_withdraw_rejects_usdc_recipient_owned_by_someone_else checks it; without the check the test's withdrawal succeeds. Claude-Session: https://claude.ai/code/session_01GZHin6BQpAqf7j2ucSZWkx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tests for errors nothing triggered
No test raised
InvalidPriceFeed,NegativePrice,StalePriceFeedorInvalidRecipient. Each check now has a test. Every test asserts the exact error and that no tokens or shares moved, and most then show the honest path succeeding.These tests are in anchor-v1, anchor and quasar:
test_wrong_price_feed_rejected: TSLAx's fresh, fully verified feed in NVDAx's place fails a deposit and a rebalance withInvalidPriceFeed.test_truncated_price_feed_rejected: a price account cut to 125 bytes, too short for a Pyth price update, fails withInvalidPriceFeed.test_non_positive_price_rejected: prices of zero and of -$180 fail withNegativePrice.test_stale_price_rejected: a price 61 seconds old fails withStalePriceFeed, and one exactly 60 seconds old is accepted.test_withdraw_rejects_recipient_owned_by_someone_elseandtest_withdraw_rejects_recipient_for_another_mintboth fail withInvalidRecipient.These are in quasar only:
test_deposit_rejects_share_account_owned_by_someone_elsetest_collect_fees_rejects_share_account_owned_by_someone_elseBoth fail with
InvalidRecipient. The Anchor versions enforce the same rule through associated token account constraints, so they raise a constraint error rather thanInvalidRecipient.The test helper
do_withdrawnow goes through a newwithdraw_tobuilder, so tests can name the recipients. The READMEs list the new tests, and each version'sCHANGELOG.mdhas an entry.Fix: quasar
withdrawchecks the USDC recipientQuasar's
withdrawchecked that each asset leg is paid to an account the holder owns for that asset's mint. It paid the USDC leg to whateveruser_usdc_accountthe caller named, while the Anchor versions require the holder's own USDC associated token account.It now checks that account's owner and mint, and fails with
InvalidRecipientif either is wrong.test_withdraw_rejects_usdc_recipient_owned_by_someone_elsecovers it.Testing
cargo testpasses:InvalidPriceFeedwhen a read runs past the end. It fails once both are removed.Not tested: the Anchor versions also map conversion failures after the length check to
InvalidPriceFeed. Those can't fire once the length check has passed.Generated by Claude Code